<template>
  <view class="normal-login-container">
    <view class="logo-content align-center justify-center flex">
      <image style="width: 89px; height: 89px" :src="globalConfig.appInfo.logo" mode="widthFix">
      </image>
    </view>
    <view class="login-form-content">
      <view class="action-btn">
        <button @click="handleLogin" class="login-btn">登录</button>
      </view>
      <view class="xieyi text-center">
        <text class="text-grey1">登录即代表同意</text>
        <text @click="handleUserAgrement" class="text-blue">《用户协议》</text>
        <text @click="handlePrivacy" class="text-blue">《隐私协议》</text>
      </view>
    </view>
  </view>
</template>

<script lang="ts" setup>
import { useConfigStore, useUserStore } from '@/stores'
import globalConfig from '@/config'
import { ServeReqNetWorkingData } from '@/services'
import { AppNavigate, PATH_LOGIN } from '@/pagePath'

// const globalConfig = useConfigStore().config

// 隐私协议
const handlePrivacy = () => {
  let site = globalConfig.appInfo.agreements[0]
  uni.navigateTo({
    url: `/pages/common/webview/index?title=${site.title}&url=${site.url}`,
  })
}
// 用户协议
const handleUserAgrement = () => {
  let site = globalConfig.appInfo.agreements[1]
  uni.navigateTo({ url: `/pages/common/webview/index?title=${site.title}&url=${site.url}` })
}

const handleLogin = () => {
  console.log('denglu')

  AppNavigate.push(PATH_LOGIN.Register)

  // uni.login({
  //   provider: 'weixin',
  //   success: function (loginRes) {
  //     console.log(loginRes)
  //     // 获取用户信息
  //     // uni.getUserInfo({
  //     //   provider: 'weixin',
  //     //   success: function (infoRes) {
  //     //     console.log('用户昵称为：' + infoRes.userInfo.nickName)
  //     //   },
  //     // })
  //     ServeReqNetWorkingData({
  //       url: '/user/wx/login',
  //       method: 'POST',
  //       params: {
  //         code: loginRes.code,
  //       },
  //     }).then((res) => {
  //       console.log(res)
  //     })
  //   },
  // })
}
</script>

<style lang="scss" scoped>
page {
  background-color: #ffffff;
}

.normal-login-container {
  width: 100%;

  .logo-content {
    width: 100%;
    font-size: 21px;
    text-align: center;
    margin-top: 221px;

    image {
      border-radius: 4px;
      width: 100px;
    }

    .title {
      margin-left: 10px;
    }
  }

  .login-form-content {
    text-align: center;
    margin: 20px auto;
    margin-top: 15%;
    width: 80%;

    .input-item {
      margin: 20px auto;
      background-color: #f5f6f7;
      height: 45px;
      border-radius: 20px;

      .icon {
        font-size: 38rpx;
        margin-left: 10px;
        color: #999;
      }

      .input {
        width: 100%;
        font-size: 14px;
        line-height: 20px;
        text-align: left;
        padding-left: 15px;
      }
    }

    .login-btn {
      margin-top: 40px;
      height: 45px;
      width: 210;
      border-radius: 7px;
      background-color: $uni-main-color;
      color: #fff;
    }

    .reg {
      margin-top: 15px;
    }

    .xieyi {
      color: #333;
      margin-top: 20px;
    }

    .login-code {
      height: 38px;
      float: right;

      .login-code-img {
        height: 38px;
        position: absolute;
        margin-left: 10px;
        width: 200rpx;
      }
    }
  }
}
</style>
